//logs.js
var util = require('../../utils/util.js')
var app = getApp()
Page({
  data: {
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    contactid:null,
    contype:null,
  },
  onLoad:function(options){
    var that  = this
    that.setData({
      contype  : options.contype,
      contactid: options.contactid
    })
    if (options.contactid) {
      app.getJson('/wxapp/base/ContactionInfo',{'contactid':options.contactid},function(res){
        console.log(res)
        that.setData({
          info: res.data,
        })
      })
    }else{
      var contactinfo = {'name':'','type_number':'','phone':'','email':''}
      that.setData({
          info: contactinfo,
      })
    }
  },
  formSubmit: function(e) {
    var that      = this
    var contype   = that.data.contype
    var contactid = that.data.contactid
    var contactinfo = {
      'type':'身份证',
      'name':e.detail.value.name,
      'type_number':e.detail.value.type_number,
      'phone':e.detail.value.phone,
      'email':e.detail.value.email
    }
    app.post('/wxapp/base/ChangeContactInfo',{'contype':contype,'contactid':contactid,'contactinfo':contactinfo},function(res){
      //console.log(res.data)
      if (res.data) {
          wx.navigateBack({
              delta: 1
          })
      }
    })

  }
})
